package marketing

import (
	"jlpay-sdk-go/pkg/jlpay/models"
)

// MerchantActivityBalanceQueryRequest 商户活动余额查询请求
type MerchantActivityBalanceQueryRequest struct {
	models.OrgBaseRequest
	// ActID 活动ID
	ActID string `json:"act_id,omitempty"`
	// MerchNo 商户号
	MerchNo string `json:"merch_no,omitempty"`
}

// NewMerchantActivityBalanceQueryRequest 创建新的商户活动余额查询请求
func NewMerchantActivityBalanceQueryRequest() *MerchantActivityBalanceQueryRequest {
	return &MerchantActivityBalanceQueryRequest{}
}

// SetActID 设置活动ID
func (m *MerchantActivityBalanceQueryRequest) SetActID(actID string) *MerchantActivityBalanceQueryRequest {
	m.ActID = actID
	return m
}

// SetMerchNo 设置商户号
func (m *MerchantActivityBalanceQueryRequest) SetMerchNo(merchNo string) *MerchantActivityBalanceQueryRequest {
	m.MerchNo = merchNo
	return m
}

// Path 获取接口路径
func (m *MerchantActivityBalanceQueryRequest) Path() string {
	return "/open/org/bank/act-bridge/act-merch/query"
}

// ToMap 将请求对象转换为map，过滤掉值为空的字段
func (m *MerchantActivityBalanceQueryRequest) ToMap() (map[string]interface{}, error) {
	data, err := m.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	// 添加当前字段
	if m.ActID != "" {
		data["act_id"] = m.ActID
	}
	if m.MerchNo != "" {
		data["merch_no"] = m.MerchNo
	}

	return data, nil
}

// MerchantActivityBalanceData 商户活动余额数据
type MerchantActivityBalanceData struct {
	// ActID 活动ID
	ActID string `json:"act_id,omitempty"`
	// MerchNo 商户号
	MerchNo string `json:"merch_no,omitempty"`
	// TermNo 终端号
	TermNo string `json:"term_no,omitempty"`
	// SortValue 计费类型
	SortValue string `json:"sort_value,omitempty"`
	// TotalQuota 总额度
	TotalQuota string `json:"total_quota,omitempty"`
	// UsedQuota 已使用额度
	UsedQuota string `json:"used_quota,omitempty"`
	// RemainingQuota 剩余额度
	RemainingQuota string `json:"remaining_quota,omitempty"`
	// StartTime 开始时间
	StartTime string `json:"start_time,omitempty"`
	// EndTime 结束时间
	EndTime string `json:"end_time,omitempty"`
	// Status 状态
	Status string `json:"status,omitempty"`
}

// NewMerchantActivityBalanceData 创建新的商户活动余额数据
func NewMerchantActivityBalanceData() *MerchantActivityBalanceData {
	return &MerchantActivityBalanceData{}
}

// SetActID 设置活动ID
func (m *MerchantActivityBalanceData) SetActID(actID string) *MerchantActivityBalanceData {
	m.ActID = actID
	return m
}

// SetMerchNo 设置商户号
func (m *MerchantActivityBalanceData) SetMerchNo(merchNo string) *MerchantActivityBalanceData {
	m.MerchNo = merchNo
	return m
}

// SetTermNo 设置终端号
func (m *MerchantActivityBalanceData) SetTermNo(termNo string) *MerchantActivityBalanceData {
	m.TermNo = termNo
	return m
}

// SetSortValue 设置计费类型
func (m *MerchantActivityBalanceData) SetSortValue(sortValue string) *MerchantActivityBalanceData {
	m.SortValue = sortValue
	return m
}

// SetTotalQuota 设置总额度
func (m *MerchantActivityBalanceData) SetTotalQuota(totalQuota string) *MerchantActivityBalanceData {
	m.TotalQuota = totalQuota
	return m
}

// SetUsedQuota 设置已使用额度
func (m *MerchantActivityBalanceData) SetUsedQuota(usedQuota string) *MerchantActivityBalanceData {
	m.UsedQuota = usedQuota
	return m
}

// SetRemainingQuota 设置剩余额度
func (m *MerchantActivityBalanceData) SetRemainingQuota(remainingQuota string) *MerchantActivityBalanceData {
	m.RemainingQuota = remainingQuota
	return m
}

// SetStartTime 设置开始时间
func (m *MerchantActivityBalanceData) SetStartTime(startTime string) *MerchantActivityBalanceData {
	m.StartTime = startTime
	return m
}

// SetEndTime 设置结束时间
func (m *MerchantActivityBalanceData) SetEndTime(endTime string) *MerchantActivityBalanceData {
	m.EndTime = endTime
	return m
}

// SetStatus 设置状态
func (m *MerchantActivityBalanceData) SetStatus(status string) *MerchantActivityBalanceData {
	m.Status = status
	return m
}

// ToMap 将对象转换为map
func (m *MerchantActivityBalanceData) ToMap() (map[string]interface{}, error) {
	data := make(map[string]interface{})

	if m.ActID != "" {
		data["act_id"] = m.ActID
	}
	if m.MerchNo != "" {
		data["merch_no"] = m.MerchNo
	}
	if m.TermNo != "" {
		data["term_no"] = m.TermNo
	}
	if m.SortValue != "" {
		data["sort_value"] = m.SortValue
	}
	if m.TotalQuota != "" {
		data["total_quota"] = m.TotalQuota
	}
	if m.UsedQuota != "" {
		data["used_quota"] = m.UsedQuota
	}
	if m.RemainingQuota != "" {
		data["remaining_quota"] = m.RemainingQuota
	}
	if m.StartTime != "" {
		data["start_time"] = m.StartTime
	}
	if m.EndTime != "" {
		data["end_time"] = m.EndTime
	}
	if m.Status != "" {
		data["status"] = m.Status
	}

	return data, nil
}

// MerchantActivityBalanceQueryResponse 商户活动余额查询响应
type MerchantActivityBalanceQueryResponse struct {
	models.StandardResponse
	// Data 商户活动余额数据列表
	Data []*MerchantActivityBalanceData `json:"data,omitempty"`
}

// NewMerchantActivityBalanceQueryResponse 创建商户活动余额查询响应
func NewMerchantActivityBalanceQueryResponse() *MerchantActivityBalanceQueryResponse {
	return &MerchantActivityBalanceQueryResponse{}
}
